package gwt.trading.client;

import gwt.trading.client.geometry.Point;
import gwt.trading.client.geometry.Size;

/**
 * @author Iulian Costan (iulian.costan@gmail.com)
 *
 */
public class DrawingBoard {

	private Translator translator;
	private Size size;

	public DrawingBoard(Point origin, Size size) {
		this.size = size;
		this.translator = new Translator(origin);
	}

	public Translator getTranslator() {
		return translator;
	}

	public Size getSize() {
		return size;
	}

	public DrawingBoard shrink(int dx, int dy, int width, int height) {
		Point origin = translator.move(dx, dy).getOrigin();
		return new DrawingBoard(origin, new Size(width, height));
	}

	/**
	 * @return min coordinate on X scale
	 */
	public int getMinXPosition() {
		return translator.translateXCoordinate(0);
	}

	/**
	 * @return max coordinate on X scale
	 */
	public int getMaxXPosition() {
		return translator.translateXCoordinate(size.getWidth());
	}

	/**
	 * @return min coordinate on Y scale
	 */
	public int getMinYPosition() {
		return translator.translateYCoordinate(0);
	}

	/**
	 * @return max coordinate on Y scale
	 */
	public int getMaxYPosition() {
		return translator.translateYCoordinate(size.getHeight());
	}

}
